<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div class="row">
    <div class="col-xs-12">
        <h4 class="lighter">
            <i class="ace-icon fa fa-hand-o-right icon-animated-hand-pointer blue"></i>
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
                启动第一个窗口
            </button>
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary" onclick="add('user/toAdd')" >
                新增
            </button>
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary" onclick="add('user/toTree')" >
                树
            </button>
        </h4>
        <!-- PAGE CONTENT BEGINS -->

        <form class="form-horizontal" id="t_userList" role="form"
              method="post">
            <div class="form-group">
                <div class="col-sm-12">
                    <label for="name" class="control-label pull-left">项目名称：</label>
                    <div class="col-sm-3">
                        <input type="text" name="name" class="form-control" id="name" placeholder="请输入项目名称" value=""/>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-primary pull-right" id="searchBtn" onclick="search('userList','t_userList')">检索</button>
                    <button type="button" class="btn btn-primary pull-right" id="clearnBtn" onclick="clearnForm('t_userList')">清空</button>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <table id="userList" rel="t_userList"></table>

                    <div id="grid-pager">
                    </div>
                </div>
            </div>
        </form>

        <!-- PAGE CONTENT ENDS -->
    </div><!-- /.col -->


    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
         data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                </div>
                <div class="modal-body">
                    1111111

                    <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal2">
                        Launch demo modal 2
                    </button>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
         data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel2">Modal title</h4>
                </div>
                <div class="modal-body">
                    22222222222

                    <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal3">
                        Launch demo modal 2
                    </button>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
         data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel3">Modal title</h4>
                </div>
                <div class="modal-body">
                    3333333
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>
    <!--Modal end-->
</div>
<script src="page/js/jqgrid.js"></script>
<!-- /.row -->
<script>
    $(function () {
        var url="user/list";
        var gridId="userList";
        var pageId="grid-pager";
        var colNames = ['选择', '姓名', '编号', '账号', '所属机构', '所属岗位', '状态','操作'];
        var caption ='用户列表';
        var colModel = [
            {index: '选择', name: 'id', hidden: true},
            {index: '姓名', name: 'name', width: 200, align:'center', editable: true},
            {index: '编号', name: 'code', width: 150, align:'center'},
            {index: '账号', name: 'regname', width: 150, align:'center'},
            {index: '所属机构', name: 'orgname', width: 240, align:'center'},
            {index: '所属岗位', name: 'post', width: 150, align:'center'},
            {
                index: '状态', name: 'status', width: 80, align:'center',
                formatter: function (cellvalue) {

                    if (cellvalue == 1) {
                        return '禁用';
                    } else if (cellvalue == 0) {
                        return '正常';
                    } else {
                        return '锁定';
                    }
                }

            },{name:'myac',index:'', width:80, fixed:true, sortable:false, align:'center', resize:false,
                formatter:'actions',
                formatoptions:{
                    keys:true,
                    //delbutton: false,//disable delete button

                    delOptions:{recreateForm: true, beforeShowForm:beforeDeleteCallback}
                    //editformbutton:true, editOptions:{recreateForm: true, beforeShowForm:beforeEditCallback}
                }
            }
        ];



        createTable(gridId, pageId, colNames, colModel, url, caption);




       /* var lastSel;

        $("#userList").jqGrid('onSelectRow',{

            onSelectRow: function(rowid,status){
                console.log("in");
                console.log(rowid);
                console.log(status);

                if(id && id!==lastSel){

                    jQuery('#gridid').restoreRow(lastSel);

                    lastSel=id;

                }

                jQuery('#userList').editRow(code, true);

            }


        })
*/



    })


</script>
